package com.timothy.junk.cbond.activity;

/**
 * Created by qtang on 7/2/13.
 */
import java.util.ArrayList;
import java.util.List;
import android.app.ListActivity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import com.timothy.junk.R;
import com.timothy.junk.ActivityManage;
import com.timothy.junk.adapter.CBondNotifyAdaptor;
import com.timothy.junk.cbond.bean.CBond;
import com.timothy.junk.cbond.bean.CBondNotify;
import com.timothy.junk.common.parse.CBondParser;

public class CBondNotifyList extends ListActivity {
	public static final String LOG_TAG = "CBondNotifyList";

    Context mContext;
    SharedPreferences sp;
    CBondNotifyAdaptor adaptor ;
    
    List<CBond> cBondList;
    List<CBondNotify> cBondNotifyList = new ArrayList<CBondNotify>();;
    
    public void loadData(){
    	cBondList = CBondParser.getCBondList(mContext);
    	for(CBond cBond: cBondList){
    		CBondNotify cbNotify = new CBondNotify(0.01,true);
    		cbNotify.setBond_name(cBond.getBond_name());
    		cBondNotifyList.add(cbNotify);
    	}
    }
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.cbond_notify_list);
        mContext = getApplicationContext();
        sp = this.getSharedPreferences("GFundApp",MODE_PRIVATE);
        
        loadData();
        
        ActivityManage.add(this);
        adaptor = new CBondNotifyAdaptor(mContext, cBondNotifyList,sp); 
        setListAdapter(adaptor);
    }

}
